//
// Created by zeng on 2022/1/22.
//

#include "MailContent.h"

MailContent::MailContent(string my_name, string your_name, Weather weather) : my_name{my_name},
                                                                              your_name{your_name},
                                                                              res_code{weather.res_code} {
    this->topic = this->your_name + "，晚安，好梦，这是明天的天气预报";
    if (weather.res_code == 200) {
        this->content =
                static_cast<string>("日期:") + static_cast<string>(weather.date) +
                static_cast<string>("\n") +
                static_cast<string>("白天天气:") + static_cast<string>(weather.textDay) +
                static_cast<string>("\n") +
                static_cast<string>("夜晚天气:") + static_cast<string>(weather.textNight) +
                static_cast<string>("\n") +
                static_cast<string>("最高:") + static_cast<string>(weather.tempMax) +
                static_cast<string>("\n") +
                static_cast<string>("最低:") + static_cast<string>(weather.tempMin) +
                static_cast<string>("\n");
    }

}

MailContent::MailContent(string my_name, string your_name, Tip tip) : my_name{my_name},
                                                                      your_name{your_name},
                                                                      res_code{tip.res_code} {
    this->topic = this->your_name + "，早上好，这是今天的一点小贴士";
    if (tip.res_code == 200) {
        this->content =
                static_cast<string>("化妆:") + static_cast<string>(tip.make_up) +
                static_cast<string>("\n") +
                static_cast<string>("晾晒:") + static_cast<string>(tip.air) +
                static_cast<string>("\n") +
                static_cast<string>("穿衣:") + static_cast<string>(tip.dress) +
                static_cast<string>("\n") +
                static_cast<string>("防晒:") + static_cast<string>(tip.anti_sunburn) +
                static_cast<string>("\n") +
                static_cast<string>("紫外线:") + static_cast<string>(tip.ultraviolet) +
                static_cast<string>("\n") +
                static_cast<string>("感冒:") + static_cast<string>(tip.cold) +
                static_cast<string>("\n") +
                static_cast<string>("运动:") + static_cast<string>(tip.anti_sunburn) +
                static_cast<string>("\n");
    }
}

MailContent::MailContent(string my_name, string your_name, Warn warn) : my_name{my_name},
                                                                        your_name{your_name},
                                                                        res_code{warn.res_code} {
    this->topic = this->your_name + "，早上好，这是今天的一点小贴士";
    if (warn.res_code == 200) {
        this->content = warn.content;
    }
}
//MailContent::MailContent(nlohmann::json mail_primer, MailType mail_type) {
//    this->topic = mail_primer["title"];
//    switch (mail_type) {
//        case MailType::WEATHER: {
//            nlohmann::json weather_json = nlohmann::json::parse(mail_primer["content"]);
//            this->content =
//                    static_cast<string>("日期:") + static_cast<string>(weather_json["日期"]) +
//                    static_cast<string>("\n") +
//                    static_cast<string>("白天天气:") + static_cast<string>(weather_json["白天天气"]) +
//                    static_cast<string>("\n") +
//                    static_cast<string>("夜晚天气:") + static_cast<string>(weather_json["夜晚天气"]) +
//                    static_cast<string>("\n") +
//                    static_cast<string>("最高:") + static_cast<string>(weather_json["最高"]) +
//                    static_cast<string>("\n") +
//                    static_cast<string>("最低:") + static_cast<string>(weather_json["最低"]) +
//                    static_cast<string>("\n");
//            break;
//        }
//        case MailType::TIP: {
//            nlohmann::json tip_json = nlohmann::json::parse(mail_primer["content"]);
//            this->content =
//                    static_cast<string>("化妆:") + static_cast<string>(tip_json["化妆"]) +
//                    static_cast<string>("\n") +
//                    static_cast<string>("晾晒:") + static_cast<string>(tip_json["晾晒"]) +
//                    static_cast<string>("\n") +
//                    static_cast<string>("穿衣:") + static_cast<string>(tip_json["穿衣"]) +
//                    static_cast<string>("\n") +
//                    static_cast<string>("防晒:") + static_cast<string>(tip_json["防晒"]) +
//                    static_cast<string>("\n") +
//                    static_cast<string>("感冒:") + static_cast<string>(tip_json["感冒"]) +
//                    static_cast<string>("\n") +
//                    static_cast<string>("运动:") + static_cast<string>(tip_json["运动"]) +
//                    static_cast<string>("\n");
//            break;
//        }
//        case MailType::WARN:
//            break;
//    }
//};
